How do I push `sed` matches to the shell call in the replacement pattern?
Posted
by rassie
on Stack Overflow
See other posts from Stack Overflow
or by rassie
Published on 2010-05-01T16:54:12Z
Indexed on
2010/05/01
16:57 UTC
Read the original article
Hit count: 238
sed
I need to replace several URLs in a text file with some content dependent on the URL itself. Let's say for simplicity it's the first line of the document at the URL.
What I'm trying is this:
sed "s/^URL=\(.*\)/TITLE=$(curl -s \1 | head -n 1)/" file.txt
This doesn't work, since \1
is not set. However, the shell is getting called. Can I somehow push the sed
match variables to that subprocess?
© Stack Overflow or respective owner